﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using vensoft.Entities;
using vensoft.BussinesLogic;

namespace vensoft.Win32
{
    public partial class frmAECategoria : Form
    {
        ICategoriaBL categoriaBL;
        public frmAECategoria()
        {
            InitializeComponent();
            categoriaBL = new CategoriaBL ();
        }
        public Categoria CurrentCatego { get; set; }

        public void Editar()
        {
            categoriaBindingSource.DataSource = CurrentCatego;
       
        }

        public void Nuevo()
        {
            Categoria currentCatego = categoriaBindingSource.Current as Categoria;
            categoriaBindingSource.AddNew();
            currentCatego = null;
            
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Guardar Información?", "CONFIRMACIÓN", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {
                MessageBox.Show("¡Información Guardada Satisfactoriamente!", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Categoria currentCatego = categoriaBindingSource.Current as Categoria;
                categoriaBL.RegistrarCategoria(currentCatego);
               
                this.Close();
            }

        }
    }
}
